$(function () {
    $.validator.addMethod('confirm', function(value, element) {
        var re = /(.*)confirm/i;
        var otherName = re.exec(element.name, '$1')[1];
        var other = element.form.elements[otherName];
        return element.value === other.value;
    });
    $('#register').validate({
        rules: {
            email: {
                required: true,
                email: true
            },
            emailConfirm: {
                required: true,
                email: true,
                confirm: true
            }
        },
        messages: {
            email: {
                required: 'Email address is missing.'
            },
            emailConfirm: {
                required: 'Email address is missing.',
                confirm: "Email addresses don't match."
            }
        }
    });
});